package com.github.demo.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import com.github.demo.dto.ArticleDto;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @GetMapping("/list")
    public ResponseEntity<List<ArticleDto>> list(){
        ArticleDto articleDto = new ArticleDto();
        articleDto.setId(1L);
        articleDto.setAuthor("liwei");
        articleDto.setContent("这是一个测试的文档");
        List<ArticleDto> articleDtos = new ArrayList<>();
        articleDtos.add(articleDto);
        return ResponseEntity.ok().body(articleDtos);
    }

    @GetMapping("/{id}")
    public ResponseEntity<ArticleDto> read(@PathVariable Long id){
        ArticleDto articleDto = new ArticleDto();
        articleDto.setId(id);
        articleDto.setAuthor("liwei");
        articleDto.setContent("这是一个测试的文档");
        return ResponseEntity.ok().body(articleDto);
    }


}
